<?php

namespace App\Containers\AppSection\Profile\Tasks;

use App\Containers\AppSection\Profile\Data\Repositories\ProfileRepository;
use App\Ship\Exceptions\NotFoundException;
use App\Ship\Parents\Tasks\Task;

class CheckProfileQualificationStatusTask extends Task
{
    protected ProfileRepository $repository;

    public function __construct(ProfileRepository $repository)
    {
        $this->repository = $repository;
    }

    public function run($id, $statuses, $in = true): bool
    {
        try {
            if ($in)
                $profile = $this->repository->findWhereIn('qualification_status_key', $statuses);
            else
                $profile = $this->repository->findWhereNotIn('qualification_status_key', $statuses);

            return !empty($profile->find($id));
        } catch (Exception $exception) {
            throw new NotFoundException(__('ship::resource.not-found'));
        }

    }
}
